package com.myk.game.gobangchess.rooms.absrooms;

import com.myk.game.gobangchess.Player;
import com.myk.game.gobangchess.Room;

/**
 * 象棋类机制抽象类，先选中棋子再移动棋子
 */
public abstract class AbsChessRoom  extends Room {
    public AbsChessRoom(String roomName, String roomIntroduce,String chessName, int[][] curGrids, boolean isSupportPersonal,boolean isSaveHistoryToFile,String ... modes) {
        super(roomName, roomIntroduce, chessName,curGrids,isSupportPersonal,isSaveHistoryToFile,modes);
    }

    @Override
    public void moveLater(Player player, int row, int col) {
        if (player_black != null && player_white != null && player_black == player_white) { //个人模式下
            if (cur == 1) {
                doRule(row, col, 1);
            }
            else if (cur == 2) {
                doRule(row, col, 2);
            }
        }
        else {//双人模式下
            if (player_black == player) {
                if (cur == 1 || cur == 3) { //3是双方都在自由布局时的阶段
                    doRule(row, col, 1);
                }
            }
            if (player_white == player) {
                if (cur == 2 || cur == 3) {//3是双方都在自由布局时的阶段
                    doRule(row, col, 2);
                }
            }
        }
    }
}
